package com.woniuxy.controller;


import com.woniuxy.commons.model.Result;
import com.woniuxy.controller.form.AddRoleMenuAuthorizationForm;
import com.woniuxy.service.RoleMenuService;
import io.lettuce.core.ConnectionEvents;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author psy
 * @since 2022-06-28
 */
@RestController
@RequestMapping("/roleMenu")
@Api(tags = "后台角色菜单操作接口")
public class RoleMenuController {

    @Autowired
    private RoleMenuService roleMenuService;


    /**
     * 超级管理员给角色授权相应菜单的接口
     * @param armaf
     * @return
     */
    @ApiOperation("超级管理员给角色授权相应菜单的接口")
    @PostMapping("/addAuthorization")
    public Result addAuthorization(@RequestBody AddRoleMenuAuthorizationForm armaf){

        Integer roleId = armaf.getRoleId();
        int[] menuIds = armaf.getMenuIds();

        roleMenuService.addAuthorization(roleId,menuIds);

        return Result.success(200,"授权菜单成功",null);

    }

}

